package ar.edu.utn.frsf.proyectofinal.sistemadecontrolmodbus.persistence.model;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name="DEVICE")
public class Device {
	
	@Id
	@Column(name="id")
	@SequenceGenerator(name = "SecuenciaDispositivo", sequenceName = "seq_dev", allocationSize = 1)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SecuenciaDispositivo")
	private Integer ID;
	
	@Column(name="name")
	private String name;
	
	@ManyToOne
	@JoinColumn(name="dev_type")
	private DeviceType type;
	
	@Column(name="description")
	private String description;
	
	@Column(name="sounding_time")
	private Integer soundingTime;
	
	@Column(name="sounding")
	private Boolean sounding;
	
	@Column(name="auto_act")
	private Boolean autoActualization;
	//Can be accessed via IP Port
	
	@Column(name="visible")
	private Boolean visible;
	
	@Column(name="ip_address")
	private String IP;
	
	@Column(name="ip_port")
	private Integer Port;
	
	@Column(name="unit_id")
	private Integer unitID;
	
	@Column(name="auto_conn")
	private Boolean autoConection;
	
	@Column(name="last_activity")
	private Date lastActivity;
	
	@OneToMany(cascade = CascadeType.ALL,mappedBy="device")
	private List<AddressValue> addressValues;
	

	/**
	 * @return the iD
	 */
	public Integer getID() {
		return ID;
	}
	/**
	 * @param iD the iD to set
	 */
	public void setID(Integer iD) {
		ID = iD;
	}
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the type
	 */
	public DeviceType getType() {
		return type;
	}
	/**
	 * @param type the type to set
	 */
	public void setType(DeviceType type) {
		this.type = type;
	}
	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}
	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}
	/**
	 * @return the soundingTime
	 */
	public Integer getSoundingTime() {
		return soundingTime;
	}
	/**
	 * @param soundingTime the soundingTime to set
	 */
	public void setSoundingTime(Integer soundingTime) {
		this.soundingTime = soundingTime;
	}
	/**
	 * @return the sounding
	 */
	public Boolean getSounding() {
		return sounding;
	}
	/**
	 * @param sounding the sounding to set
	 */
	public void setSounding(Boolean sounding) {
		this.sounding = sounding;
	}
	/**
	 * @return the autoActualization
	 */
	public Boolean getAutoActualization() {
		return autoActualization;
	}
	/**
	 * @param autoActualization the autoActualization to set
	 */
	public void setAutoActualization(Boolean autoActualization) {
		this.autoActualization = autoActualization;
	}
	/**
	 * @return the visible
	 */
	public Boolean getVisible() {
		return visible;
	}
	/**
	 * @param visible the visible to set
	 */
	public void setVisible(Boolean visible) {
		this.visible = visible;
	}
	/**
	 * @return the iP
	 */
	public String getIP() {
		return IP;
	}
	/**
	 * @param iP the iP to set
	 */
	public void setIP(String iP) {
		IP = iP;
	}
	/**
	 * @return the port
	 */
	public Integer getPort() {
		return Port;
	}
	/**
	 * @param port the port to set
	 */
	public void setPort(Integer port) {
		Port = port;
	}
	/**
	 * @return the unitID
	 */
	public Integer getUnitID() {
		return unitID;
	}
	/**
	 * @param unitID the unitID to set
	 */
	public void setUnitID(Integer unitID) {
		this.unitID = unitID;
	}
	/**
	 * @return the autoConection
	 */
	public Boolean getAutoConection() {
		return autoConection;
	}
	/**
	 * @param autoConection the autoConection to set
	 */
	public void setAutoConection(Boolean autoConection) {
		this.autoConection = autoConection;
	}
	/**
	 * @return the lastActivity
	 */
	public Date getLastActivity() {
		return lastActivity;
	}
	/**
	 * @param lastActivity the lastActivity to set
	 */
	public void setLastActivity(Date lastActivity) {
		this.lastActivity = lastActivity;
	}
	/**
	 * @return the addressValues
	 */
	public List<AddressValue> getAddressValues() {
		return addressValues;
	}
	/**
	 * @param addressValues the addressValues to set
	 */
	public void setAddressValues(List<AddressValue> addressValues) {
		this.addressValues = addressValues;
	}
	

}
